package com.ruoyi.buss.grid.zysc.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.buss.grid.zysc.domain.DataWgZyscKh;
import com.ruoyi.buss.grid.zysc.service.IDataWgZyscKhService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 专业市场客户Controller
 * 
 * @author sxy
 * @date 2021-09-26
 */
@RestController
@RequestMapping("/zyscKh")
public class DataWgZyscKhController extends BaseController
{
    @Autowired
    private IDataWgZyscKhService dataWgZyscKhService;

    /**
     * 查询专业市场客户列表
     */
    @PreAuthorize(hasPermi = "buss:zyscKh:list")
    @GetMapping("/list")
    public TableDataInfo list(DataWgZyscKh dataWgZyscKh)
    {
        startPage();
        List<DataWgZyscKh> list = dataWgZyscKhService.selectDataWgZyscKhList(dataWgZyscKh);
        return getDataTable(list);
    }

    /**
     * 导出专业市场客户列表
     */
    @PreAuthorize(hasPermi = "buss:zyscKh:export")
    @Log(title = "专业市场客户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataWgZyscKh dataWgZyscKh) throws IOException
    {
        List<DataWgZyscKh> list = dataWgZyscKhService.selectDataWgZyscKhList(dataWgZyscKh);
        ExcelUtil<DataWgZyscKh> util = new ExcelUtil<DataWgZyscKh>(DataWgZyscKh.class);
        util.exportExcel(response, list, "专业市场客户数据");
    }

    /**
     * 获取专业市场客户详细信息
     */
    @PreAuthorize(hasPermi = "buss:zyscKh:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(dataWgZyscKhService.selectDataWgZyscKhById(id));
    }

    /**
     * 新增专业市场客户
     */
    @PreAuthorize(hasPermi = "buss:zyscKh:add")
    @Log(title = "专业市场客户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataWgZyscKh dataWgZyscKh)
    {
        return toAjax(dataWgZyscKhService.insertDataWgZyscKh(dataWgZyscKh));
    }

    /**
     * 修改专业市场客户
     */
    @PreAuthorize(hasPermi = "buss:zyscKh:edit")
    @Log(title = "专业市场客户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataWgZyscKh dataWgZyscKh)
    {
        return toAjax(dataWgZyscKhService.updateDataWgZyscKh(dataWgZyscKh));
    }

    /**
     * 删除专业市场客户
     */
    @PreAuthorize(hasPermi = "buss:zyscKh:remove")
    @Log(title = "专业市场客户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dataWgZyscKhService.deleteDataWgZyscKhByIds(ids));
    }
}
